package cn.edu.nju.ws.sview.views;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Properties;

import cn.edu.nju.ws.sview.database.DBConnectionFactory;
import cn.edu.nju.ws.sview.rdf.ResourceFactory;


public abstract class DataMember{
	public final static String CLEAR_TMP_DATAMEMBER = "clear_tmp_datamember" ;
	public static final int CUSTOM_DATAMEMBER;
	public static final int URI_DATAMEMBER;
	public static final int VALUE_TYPE_LINK;
	public static final int VALUE_TYPE_ATTRIBUTE ;
	public static final int MAKE_METHOD_MERGE ;
	public static final int MAKE_METHOD_CHAIN ;
	static{
		Properties properties = new Properties();
		try {
			properties.load(ResourceFactory.class.getClassLoader().getResourceAsStream("conf.properties")) ;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		CUSTOM_DATAMEMBER = Integer.parseInt(properties.getProperty("custom_datamember"));
		URI_DATAMEMBER = Integer.parseInt(properties.getProperty("uri_datamember"));
		VALUE_TYPE_LINK = Integer.parseInt(properties.getProperty("value_type_link"));
		VALUE_TYPE_ATTRIBUTE = Integer.parseInt(properties.getProperty("value_type_attribute"));
		MAKE_METHOD_MERGE = Integer.parseInt(properties.getProperty("make_method_merge"));
		MAKE_METHOD_CHAIN = Integer.parseInt(properties.getProperty("make_method_chain"));
		properties.clear();
	}
	
	public static class DataMemberItem{
		public int dmtype;
		public int dmid;
		public boolean inverse;
		public DataMemberItem(int dmtype,int dmid,boolean inverse){
			this.dmtype = dmtype;
			this.dmid = dmid;
			this.inverse = inverse;
		}
		
		public int getDMType(){
			return this.dmtype;
		}
		
		public int getDMID(){
			return this.dmid;
		}
		
		public boolean getInverse(){
			return this.inverse;
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + dmid;
			result = prime * result + dmtype;
			result = prime * result + (inverse ? 1231 : 1237);
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			DataMemberItem other = (DataMemberItem) obj;
			if (dmid != other.dmid)
				return false;
			if (dmtype != other.dmtype)
				return false;
			if (inverse != other.inverse)
				return false;
			return true;
		}
		
		
	}
}
